package cn.jiyun;import cn.jiyun.common.config.ESClientUtil;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@SpringBootApplication
@EnableDiscoveryClient
public class BeginLogin {
    public static void main(String[] args) {
        SpringApplication.run(BeginLogin.class,args);
//        RestHighLevelClient client = ESClientUtil.getClient();
//        String indexName = "sensitive-words-index";
//        List<String> sensitiveWords = new ArrayList<>();
//        sensitiveWords.add("色情");
//        sensitiveWords.add("暴力");
//        sensitiveWords.add("赌博");
//        BulkRequest bulkRequest = new BulkRequest();
//        for (String word : sensitiveWords) {
//            IndexRequest indexRequest = new IndexRequest(indexName).source("{" +
//                    "    \"word\": \"" + word + "\"" +
//                    "}", XContentType.JSON);
//            bulkRequest.add(indexRequest);
//        }
//        try {
//            BulkResponse response = client.bulk(bulkRequest, RequestOptions.DEFAULT);
//            System.out.println("批量存储结果：" + response.hasFailures());
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
    }
}
